<?php
include('../incsession.php');


$_SESSION['posted']='no';

if(isset($_POST['do_forum'])){
	$_SESSION['do_dnd'] = 0;//first in
	$_SESSION['do_forum'] = 0;
	header('location: forum.php');
}
else if(isset($_POST['do_dnd'])){
	$_SESSION['do_dnd'] = 0;//first in
	$_SESSION['do_forum'] = 0;
	header('location: abstract_drag_and_drop.php');
}
include("timer.php");
?>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>sample page</title>
<link rel="stylesheet" href="style.css" type="text/css" media="screen">
<script type="text/javascript" src="jquery.min.js"></script>
<script>

function split_paragraph(num){
	var obj = "#para"+num;
	var obj2 = "#ifsplit"+num;
	var obj3 = "#paragraphend"+num;
	if($(obj2).val()==0){
		
		if($(obj3).val()==0){
			$(obj).html("<br><br><img src='./img/wrong.png' width=24 height=24>");
			$(obj2).val(1);
		}
		else{
			$(obj).html("<br><br><img src='./img/right.png' width=24s height=24>");
			$(obj2).val(1);
			//<img src='./img/goback.gif' width=12 height=12>
		}
	}
	else{
		$(obj).html("<img src='./img/marker.png' >");
		$(obj2).val(0);
	}	
}
/*association & dictionary*/
/**
			 * Copyright (c) 2009 Mark S. Kolich
			 * http://mark.kolich.com
			 *
			 * Permission is hereby granted, free of charge, to any person
			 * obtaining a copy of this software and associated documentation
			 * files (the "Software"), to deal in the Software without
			 * restriction, including without limitation the rights to use,
			 * copy, modify, merge, publish, distribute, sublicense, and/or sell
			 * copies of the Software, and to permit persons to whom the
			 * Software is furnished to do so, subject to the following
			 * conditions:
			 *
			 * The above copyright notice and this permission notice shall be
			 * included in all copies or substantial portions of the Software.
			 *
			 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
			 * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
			 * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
			 * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
			 * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
			 * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
			 * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
			 * OTHER DEALINGS IN THE SOFTWARE.
			*/
			
			if(!window.Kolich){
				Kolich = {};
			}
			
			Kolich.Selector = {};
			// getSelected() was borrowed from CodeToad at
			// http://www.codetoad.com/javascript_get_selected_text.asp
			Kolich.Selector.getSelected = function(){
				var t = '';
				if(window.getSelection){
					t = window.getSelection();
				}else if(document.getSelection){
					t = document.getSelection();
				}else if(document.selection){
					t = document.selection.createRange().text;
				}
				return t;
			}
			
			Kolich.Selector.mouseup = function(e){
				$('#dict_div').hide();
				$('#assoc_div').hide();
				var st = Kolich.Selector.getSelected();
				st=st.toString();
				if(st!='' && st!=' '){
					//alert("You selected:\n"+st);
					//getting height and width of the message box
					//calculating offset for displaying popup message
					leftVal=e.pageX+"px";
					topVal=e.pageY-32+"px"; 
					//show the popup message and hide with fading effect
					$('#dict_div').css({left:leftVal,top:topVal}).show();
					$('#dict_text').val(st);
					
					if(st.charAt(0)==" ")
						st=st.substring(1);	
					if(st.charAt(st.length-1)==" ")
						st=st.substring(0,st.length-1);
					if(st.indexOf(" ")==-1){
						leftVal=e.pageX+35+"px";
						$('#assoc_div').css({left:leftVal,top:topVal}).show();
						$('#assoc_text').val(st);
					}
				}
				else{
					$('#dict_div').hide();
					$('#assoc_div').hide();
				}
			}
			
			$(document).ready(function(){
				$(document).bind("mouseup", Kolich.Selector.mouseup);
			});
			
			function dict()
			{
				window.open("http://www.google.com.tw/dictionary?langpair=en|zh-TW&q="+$('#dict_text').val(), "dict");
			}
			
			
			var record=new Array();
			var count=0;
			var z_idx=1;
			var Browser=(function x(){})[-5]=='x'?'FF3':(function x(){})[-6]=='x'?'FF2':/a/[-1]=='a'?'FF':'\v'=='v'?'IE':/a/.__proto__=='//'?'Saf':/s/.test(/a/.toString)?'Chr':/^function \(/.test([].sort)?'Op':'Unknown';
																																																	 			function delete_voc(str){
				if(Browser=="IE")
					var replace_str=str+" <SPAN onclick="+'"'+"delete_voc('"+str+"')"+'"'+">x</SPAN><BR>";
				else
					var replace_str=str+" <span onclick="+'"'+"delete_voc('"+str+"')"+'"'+">x</span><br>";
				document.getElementById("cart").innerHTML=document.getElementById("cart").innerHTML.replace(replace_str,"");	
			}
			function getElementsByName_iefix(tag, name) { 
				var elem = document.getElementsByTagName(tag); 
				var arr = new Array(); 
				var iarr=0;
				var i;
				var att;
				for (i = 0 ; i < elem.length; i++ ) {
					att = elem[i].name; 
					if (att == name) { 
						arr[iarr] = elem[i]; 
						iarr++ ; 
						break;
					} 
				} 
				return arr; 
			}  
			function assoc(){
				var str=$('#assoc_text').val();
				document.getElementById("association_title").innerHTML="&nbsp;"+str;
				var elem;
				if(Browser=="IE")
					elem=getElementsByName_iefix("textarea", str)[0];
				else
					elem=document.getElementsByName(str)[0];
				if(elem!=null){
				//vocabulary cart
					if(document.getElementById("cart").innerHTML.search(str)==-1)
						document.getElementById("cart").innerHTML+=str+" <span onclick=\"delete_voc('"+str+"')\">x</span><br>";
				//association
					elem.style.zIndex=z_idx;
					z_idx++;
				}
				else{
					//vocabulary cart
					document.getElementById("cart").innerHTML+=str+" <span onclick=\"delete_voc('"+str+"')\">x</span><br>";
					//association		
					document.getElementById("record_arry").innerHTML+="<input type='hidden' name='record_"+count+"' value='"+str+"'>";
					count++;
					document.getElementsByName("record_count")[0].value=count;
					var newtxt=document.createElement('textarea');
			
					if(Browser=='IE'){
						newtxt.className="assoc_textarea";
						newtxt.name=str;
						newtxt.style.zIndex=z_idx;
					}
					else{
						newtxt.setAttribute("CLASS","assoc_textarea");
						newtxt.setAttribute("NAME",str);
						newtxt.setAttribute("STYLE","z-index:"+z_idx);
					}
					newtxt.innerHTML="在這裡寫下你對單字的聯想!";
			
					document.getElementById("association").appendChild(newtxt);
					z_idx++;
				}
			}

/*association & dictionary*/
</script>
<style type="text/css">
.assoc_msg{
  position:absolute;
  z-index:10;   
  width:35px;
  height:35px;
  text-align:center;
  background:url(img/association.png) bottom right no-repeat;
  display:none;
}
.dict_msg{
  position:absolute;
  z-index:10;   
  width:35px;
  height:35px;
  text-align:center;
  background:url(img/question.png) bottom right no-repeat;
  display:none;
}
</style>
</head>

<body onLoad="TimeCountDown()">

<input id="assoc_text" type="hidden">
<div id="assoc_div" class="assoc_msg" onClick="assoc()"></div>
<input id="dict_text" type="hidden">
<div id="dict_div" class="dict_msg" onClick="dict(),assoc()"></div>

<div id="wrapper">
	<div id="header">
		<div id="logo"></div>
		<div id="menu">
        <?php
			include("menu.php");
		?>
        <!--
			<a href="">首頁</a> | <a href="">成績</a> | <a href="">註冊班級</a> | <a href="">帳號</a> | <a href="">線上聽力</a> | <a href="">聯絡我們</a> | <a href="">版本說明</a>
            !-->
		</div>
	</div>
	<div class="clearer"></div>
	<div class="edge-top"></div>

	<div id="main">

		<div id="title">閱讀摘要<font size=4><br>這篇文章是主要文章的引導和摘要</font></div>
<hr/><br><br>

<!-- 內文開始 !-->
<?php

$query = "SELECT abstract from abstract where topicid = ".$_SESSION['topic']." and level = ".$_SESSION['level'];
$result = mysql_query($query,$orcp_con);
$row = mysql_fetch_row($result);
echo $row[0];
?>
<br><br>

<form action="abstract.php" method='Post'>

<form action="abstract.php">

	<table width="100%">
	<tr><td align='right'><input type='submit' name='do_forum' value='下一步 >> 先到討論區'></td></tr>
	<tr><td align='right'><input type='submit' name='do_dnd' value='下一步 >> 先做大綱練習'></td></tr>
	</table>
</form>
<!-- 內文結束 !-->

	</div>
    <div class="edge-bottom"></div>
    <div id="footer"><?php  include("footer.php"); ?></div>
</div>

<div id="txt">18:27</div>
<input type="hidden" name="record_count" value=0>
<span id="record_arry"></span>
<div id="association"><span id="association_title">&nbsp;association</span></div>
<div id="voc_cart">&nbsp;vocabulary cart
<div id="cart"></div>

</body>
</html>